package com.sn.flink.streaming.customer.source;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.windowing.time.Time;

public class Demo4RichParalleSource {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.addSource(new RichParalleSource())
                .map((MapFunction<Long, Long>) aLong -> {
                    System.out.println("接收到数据：" + aLong);
                    return aLong;
                })
                .timeWindowAll(Time.seconds(2))
                .sum(0)
                .print();
        env.execute();
    }
}
